<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">

        <!-- 内容的坑 -->
        <router-view name="default"></router-view>

        <!-- 导航坑 -->
        <router-view name="nav"></router-view>
    </div>
    <template id="mynav">
        <ul>
            <li>
                <router-link to="/home">首页</router-link>
            </li>
            <li>
                <router-link to="/login">登录</router-link>
            </li>
        </ul>
    </template>
    <script src="./node_modules/vue/dist/vue.js"></script>
    <script src="./node_modules/vue-router/dist/vue-router.js"></script>
    
    <script>
        let myNav = {
            template: "#mynav"
        }

        let home = {
            template: "<div>home</div>"
        }

        let login = {
            template: "<div>这是Login页面</div>"
        }

        const routes = [
            {
                path: "/home",
                components: {
                    nav: myNav,
                    default: home
                }
            },
            {
                path: "/login",
                component: login
            }
        ]

        const router = new VueRouter({
            routes
        })

        const app = new Vue({
            el: "#app",
            router
        })
    </script>
</body>
</html>